package com.retailshop.shopuser.UserTask;

import com.retailshop.shopuser.service.UserShareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
public class UserShareAuto {

    @Autowired
    UserShareService userShareService;

    @ResponseBody
    @RequestMapping("/UserShare")
    public int UserShare(HttpServletRequest request) {
        int r= userShareService.UserShare1();
        return r;
    }

    @ResponseBody
    @RequestMapping("/test")
    public int test(HttpServletRequest request) {

        return 0;
    }

    @ResponseBody
    @RequestMapping("/FinishingUserShare")
    public int FinishingUserShare(HttpServletRequest request,@RequestParam Map<String, Object> map) {

        int id =1000;
        try {
            id = Integer.parseInt(map.get("id").toString());
        }catch (Exception ex)
        {}

        int r= userShareService.FinishingUserShare(id);
        return r;
    }

    @ResponseBody
    @RequestMapping("/FinishingUserShareAll")
    public int FinishingUserShareAll(HttpServletRequest request,@RequestParam Map<String, Object> map) {

        int minId =0;
        try {
            minId = Integer.parseInt(map.get("minId").toString());
        }catch (Exception ex)
        {}

        int r= userShareService.FinishingUserShareAll(minId);
        return r;
    }

    @ResponseBody
    @RequestMapping("/FinishingUserShareMinId")
    public int FinishingUserShareMinId(HttpServletRequest request) {

        int r= userShareService.FinishingUserShareMinId();
        return r;
    }


}
